import java.util.Scanner;

public class Day_32_1_淘宝网店 {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        while(scan.hasNext()) {
            int yearStart = scan.nextInt();
            int monthStart = scan.nextInt();
            int dayStart = scan.nextInt();

            int yearEnd = scan.nextInt();
            int monthEnd = scan.nextInt();
            int dayEnd = scan.nextInt();
            int money = money(yearStart,monthStart,dayStart,
                    yearEnd,monthEnd,dayEnd);
            System.out.println(money);
        }
    }

    private static boolean isSu(int num) {
        if(num == 1) return false;
        if (num == 2) return true;
        for(int i = 2; i <= num/2; i++) {
            if(num % i == 0) {
                return false;
            }
        }
        return true;
    }
    private static boolean isRun(int year) {
        return ((year % 4 == 0 && year % 100 != 0) || year % 400 == 0);
    }

    private static int money(int y1, int m1, int d1, int y2, int m2, int d2) {
        int sum = 0;
        int s1[] = { 0, 62, 28, 31, 60, 31, 60, 31, 62, 60, 62, 30, 62 };
        int s2[] = { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 };
        if(y1 == y2 && m1 == m2) {
            int n = 0;
            if(isSu(m1)) {
                n += d2 - d1 + 1;
            }else {
                n += 2 * (d2 - d1 + 1);
            }
            sum = n;
        }else if(y1 == y2 && m1 != m2) {
            int n = 0;
            if (!isRun(y1)) {
                for (int i = m1 + 1; i < m2; i++) {
                    n += s1[i];
                }
                if(isSu(m1) && isSu(m2)) {
                    n += s2[m1] - d1 + 1 + s2[m2] - d2 + 1;
                }else if(!isSu(m1) && !isSu(m2)) {
                    n += 2 * (s2[m1] - d1 + 1 + s2[m2] - d2 + 1);
                }else if(!isSu(m1) && isSu(m2)) {
                    n += 2 * (s2[m1] - d1 + 1) + s2[m2] - d2 + 1;
                }else {
                    n += s2[m1] - d1 + 1 + 2 * (s2[m2] - d2 + 1);
                }
            }else {
                if (m1 < 2 && 2 < m2) {
                    n += 1;
                }
            }
            sum = n;
        }else {
            int n = 0;
            for (int i = y1+1; i < y2; i++) {
                if (!isRun(i)) {
                    n += 579;
                }else {
                    n += 580;
                }
            }
            for (int i = m1 + 1; i < m2; i++) {
                if (isRun(y1) && i == 2) {
                    n += 1;
                }
                n += s1[i];
            }
            if(isSu(m1)) {
                n += s2[m1] - d1 + 1;
            }else {
                n += 2 * (s2[m1] - d1 + 1);
            }
            for (int i = 1; i < m2; i++) {
                if (isRun(y2) && i == 2) {
                    n += 1;
                }
                n += s1[i];
            }
            if (isSu(m2)) {
                n += d2;
            }else {
                n += 2 * d2;
            }
            sum = n;
        }
        return sum;
    }
}
